home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_04
/
allison
/
lifetime.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1994-02-10
|
319 b
|
30 lines
LISTING 3 -
/* lifetime.c: Illustrate static storage duration */
#include <stdio.h>
main()
{
int count(void);
int i;
for (i = 0; i < 5; ++i)
printf("%d\n",count());
return 0;
}
int count(void)
{
static int n = 0;
return ++n;
}
/* Output:
1
2
3
4
5
*/